package com.base.cn.platform.os.service.manage.op.article;

import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.manage.BaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 资讯接口
 * @author zsw
 * @create 2018-05-3
 */
@FeignClient(name = BaseService.appName , configuration = FeignAuthConfig.class)
public interface OpArticleService extends BaseService {

    /**
     * 查询资讯数量
     * @param article
     * @create 2018-05-3
     */
    @RequestMapping(contextPath + "/op/articleCount")
    BigDecimal count(@RequestBody Map<String, Object> article);

    /**
     * 查询资讯列表
     * @param currentPage 分页
     * @param article 查询条件
     * @create 2018-05-3
     */
    @RequestMapping(contextPath + "/op/queryArticleList")
    Map<String,Object> queryArticleList(@RequestParam(value = "currentPage", required = false, defaultValue = "1") int currentPage,
                                        @RequestBody Map<String, Object> article);

    /**
     * 保存/更新资讯
     * @param article
     * @create 2018-05-3
     */
    @RequestMapping(contextPath + "/op/saveUpdateArticle")
    Map<String ,Object> saveUpdateArticle(@RequestBody Map<String, Object> article);

    /**
     * 删除资讯
     * @param articleIds 资讯Id串
     * @create 2018-05-3
     */
    @RequestMapping(contextPath + "/op/deleteArticle")
    Map<String,Object> deleteArticle(@RequestParam("articleIds") String articleIds);

    /**
     * 根据ID查询资讯
     * @param id 资讯id
     * @param setRecommend 设置推荐
     * @param count 推荐条数
     * @return
     */
    @RequestMapping(contextPath + "/op/findArticleById")
    Map<String, Object> findArticleById(@RequestParam("id") BigDecimal id,
                                        @RequestParam(value = "setRecommend", required = false) boolean setRecommend,
                                        @RequestParam(value = "count", required = false, defaultValue = "5") int count);

    /**
     * 修改资讯状态
     * @param articleIds 资讯id串
     * @param status 状态：1.正常 2.禁用 3.删除
     * @return
     */
    @RequestMapping(contextPath + "/op/updateArticleStatusByIds")
    Map<String, Object> updateArticleStatusByIds(@RequestParam("articleIds") String articleIds,
                                                 @RequestParam("status") Integer status);

    /**
     * 资讯批量发布
     * @param articleIds 资讯id串
     * @return
     */
    @RequestMapping(contextPath + "/op/batchPublishArticle")
    Map<String, Object> batchPublishArticle(@RequestParam("articleIds") String articleIds);

    /**
     * 根据Ids搜索资讯
     * @param articleIds
     * @return
     */
    @RequestMapping(contextPath + "/op/opArticleMapByIds")
    Map<BigDecimal,Map<String,Object>> opArticleMapByIds(@RequestParam("articleIds") String articleIds,
                                                         @RequestParam("status") Integer status,
                                                         @RequestParam("setContext") boolean setContext,
                                                         @RequestParam("setType") boolean setType);

    /**
     * 查询试卷列表
     * @param article
     * @return
     */
    @RequestMapping(contextPath + "/op/findOpArticleList")
    List<Map<String, Object>> findOpArticleList(@RequestBody Map<String, Object> article);
}
